<?php

namespace App\Controllers;

use App\Services\HallMenuService;
use common\enum\CommonEnum;
use common\enum\HallMenuEnum;
use Illuminate\Http\Request;
use common\utils\SysCode;
use App\Services\PayChannelService;


/**
 * 厅主导航菜单相关
 * Class HallMenu
 * @package App\Controllers
 */
class HallMenuController extends BaseController
{

    //H5游戏大类列表
    public function getMenuList(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
        ]);
        $type = $request->input("type", 2);
        return HallMenuService::getH5MenuList($request['hall_id'], $type);
    }

    //设置是否在前端显示
    public function setList(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
            'list' => 'required'
        ]);
        $data = [
            'hall_id' => $request->input('hall_id'),
            'list' => $request->input('list'),
            'is_hot' => $request->input('is_hot'),
            'is_display_icon' => $request->input('is_display_icon'),
        ];
        return HallMenuService::setDisplay($data);
    }

    //获取当前厅所有的api列表
    public function getHallApiList(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
        ]);
        $hall_id = $request->input("hall_id");
        $type = $request->input("type", 1);
        return HallMenuService::getApiList($hall_id, $type);
    }

    //保存设置对应api
    public function setApi(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
            'id' => 'required',
            'name' => 'required',
            'list' => 'required',
        ]);
        $params = [
            'hall_id' => $request['hall_id'],
            'id' => $request['id'],
            'list' => $request['list'],
            'name' => $request['name'],
        ];
        return HallMenuService::setApiList($params);
    }


    //获取编辑前的info信息
    public function setApiInfo(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
            'id' => 'required',
        ]);

        $type = $request->input("type", 1);
        return HallMenuService::getEditInfoList($request['hall_id'], $request['id'], $type);
    }

    //电子首页添加
    public function addMenu(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
            'name' => 'required',
        ]);
        $sort = $request->input("sort", 10);
        $display = $request->input("is_display", 0);
        $list = $request->input("list", []);
        return HallMenuService::addMenuData($request['hall_id'], $request['name'], $list, $sort, $display);
    }

    //删除对应的PC电子菜单
    public function removeMenu(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
            'ids' => 'required',
        ]);
        return HallMenuService::removeData($request['hall_id'], $request['ids']);
    }

    //PC导航新增菜单
    public function addPcMenu(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
            'list' => 'required',
        ]);
        $hallId = $request->input("hall_id", 0);
        $list = $request->input("list",[]);
        return HallMenuService::addPcMenuDataList($hallId, $list);
    }

    //编辑pc端一菜单
    public function editPcMenu(Request $request)
    {
        $this->validate($request, [
            'id' => 'required',
            'hall_id' => 'required',
            'name' => 'required',
            'jump_switch' => 'required',
            'color' => 'required',
            'is_hot' => 'required',
        ]);
        $id = $request->input("id", 0);
        $hallId = $request->input("hall_id", 0);
        $jump_switch = $request->input("jump_switch", 0);
        $is_hot = $request->input("is_hot", 0);
        $name = $request->input("name", 0);
        $color = $request->input("color", 0);
        $list = $request->input("list", []);
        $child = $request->input("child", []);
        return HallMenuService::editPcMenuData($id, $hallId, $name, $jump_switch, $is_hot, $list, $color,$child);
    }
}